package com.sdy.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @program: ssm1205-2
 * @author: sdy
 * @create: 2022-12-05 16:01
 **/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class R<T> {
    private  int code;
    private String message;
    private T data;
    //成功
    public static<T> R ok(T data){
        R r = new R(200,"ok",null);
        r.setData(data);
        return r;
    }
    //失败
    public static<T> R fail(T data){
        R r = new R(300,"fail",null);
        r.setData(data);
        return r;
    }
    //异常
    public static<T> R exp(T data){
        R r = new R(400,"exp",null);
        r.setData(data);
        return r;
    }
}
